package transactionimplementation

import (
	"reflect"
	Database "salarypayment-case/DataBase"
	"salarypayment-case/modelimplementation"
	"time"
)


type ServiceChargeTransaction struct {
	itsDate time.Time
	itsCharge float64
	itsMemberId int
}

func (st *ServiceChargeTransaction) Execute() {
	e := Database.PayrollDatabases.GetUnionMember(st.itsMemberId)
	af := e.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(modelimplementation.UnionAffiliation{}) {
		uaf := af.(*modelimplementation.UnionAffiliation)
		uaf.AddServiceCharge(st.itsDate,st.itsCharge)
	}
}